package com.sunshine.feign;

import com.sunshine.feign.bean.Person;
import com.sunshine.feign.bean.Result;
import com.sunshine.feign.server.IPersonClient;
import feign.Feign;
import feign.jaxb.JAXBContextFactory;
import feign.jaxb.JAXBDecoder;
import feign.jaxb.JAXBEncoder;

/**
 * @author WeiHong
 * @date 2018/11/19
 */
public class XmlTest {

    public static void main(String[] args) {
        JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder().build();
        IPersonClient personClient = Feign.builder()
                .encoder(new JAXBEncoder(jaxbFactory))
                .decoder(new JAXBDecoder(jaxbFactory))
                .target(IPersonClient.class, "http://localhost:8081");
        Person person = new Person(1, "WeiHong", 20);
        person.setMessage("你好");
        Result result = personClient.createXmlPerson(person);
        System.out.println("result.getMessage() = " + result.getMessage());

    }
}
